<template>
  <el-dialog title="查看" :visible.sync="visible" width="60%">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="110px">
      <el-form-item label="宠物主人" prop="nickName">
        <el-input v-model="dataForm.nickName" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="宠物名称" prop="petName">
        <el-input v-model="dataForm.petName" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="宠物身高" prop="height">
        <el-input v-model="dataForm.height" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="宠物体重" prop="weight">
        <el-input v-model="dataForm.weight" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="主治医生" prop="medicId">
        <el-input v-model="dataForm.medicName" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="查看时间" prop="time">
        <el-input v-model="dataForm.time" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="病因" prop="petIntro">
        <el-input v-model="dataForm.petIntro" type="textarea" :rows="4" clearable placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="治疗措施" prop="measure">
        <el-input v-model="dataForm.measure" type="textarea" :rows="4" clearable placeholder="请输入"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import { getDataInfo } from '@/api/apply';
  import { mapGetters } from 'vuex';
  export default {
    data() {
      return {
        visible: false,
        dataForm: {},
        dataRule: {
        },
      };
    },
    computed: {
      ...mapGetters(['userInfo'])
    },
    mounted() {
    },
    methods: {
      init(id) {
        this.visible = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields();
          this.dataForm = { id, userId: this.userInfo.id, nickName: this.userInfo.name };
          if (id) {
            getDataInfo(id)
              .then((data) => {
                if (data && data.code === 0) {
                  this.dataForm = data.data;
                }
              })
              .catch((err) => {
                console.log(err);
              });
          }
        });
      },
    },
  };
</script>
